# -*- coding: utf-8 -*-
# File : config.py
# Author: taoyahui
# Date : 2021/10/17

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_cors import *
import redis

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = "mysql://root:123456@127.0.0.1:3306/data_export"
db = SQLAlchemy(app)
# r'/*' 是通配符，让本服务器所有的URL 都允许跨域请求
CORS(app, resources=r'/*')

admin_address = '0x5562ce8064b1f13639249acfe45c9966dd95522c'
contract_name = 'FoodTraceNew'
contract_address = '0x45fcfb436fd7c3489b27ef6142eaad91e4f87d18'
contract_abi =[{"constant":False,"inputs":[{"name":"userAddress","type":"address"},{"name":"newrole","type":"uint256"}],"name":"changeRole","outputs":[],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":False,"inputs":[{"name":"foodId","type":"uint256"},{"name":"name","type":"string"},{"name":"foodType","type":"string"},{"name":"quality","type":"string"},{"name":"spec","type":"string"},{"name":"other","type":"string"}],"name":"createFood","outputs":[{"name":"","type":"uint256"}],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":False,"inputs":[{"name":"orderNo","type":"uint256"},{"name":"prodNo","type":"uint256"},{"name":"orderType","type":"uint256"},{"name":"foodId","type":"uint256"},{"name":"price","type":"uint256"},{"name":"num","type":"uint256"}],"name":"Produces","outputs":[{"name":"","type":"uint256"}],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":True,"inputs":[{"name":"","type":"uint256"}],"name":"orderMap","outputs":[{"name":"orderNo","type":"uint256"},{"name":"num","type":"uint256"},{"name":"foodId","type":"uint256"},{"name":"price","type":"uint256"},{"name":"userAddress","type":"address"},{"name":"updateTime","type":"uint256"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":True,"inputs":[{"name":"id","type":"uint256"}],"name":"getFood","outputs":[{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"uint256"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":False,"inputs":[{"name":"orderNo","type":"uint256"},{"name":"transportNo","type":"uint256"},{"name":"orderType","type":"uint256"},{"name":"num","type":"uint256"},{"name":"from_place","type":"string"},{"name":"to_place","type":"string"}],"name":"Transport","outputs":[{"name":"","type":"uint256"}],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":True,"inputs":[{"name":"userAddress","type":"address"}],"name":"getUserRole","outputs":[{"name":"","type":"uint256"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":True,"inputs":[{"name":"userAddress","type":"address"}],"name":"getMember","outputs":[{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":True,"inputs":[{"name":"id","type":"uint256"}],"name":"getProduce","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"address"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":False,"inputs":[{"name":"userAddress","type":"address"}],"name":"removeRole","outputs":[],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":False,"inputs":[{"name":"id","type":"uint256"}],"name":"checkid","outputs":[{"name":"","type":"bool"}],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":False,"inputs":[{"name":"orderNo","type":"uint256"},{"name":"buyNo","type":"uint256"},{"name":"orderType","type":"uint256"},{"name":"foodId","type":"uint256"},{"name":"price","type":"uint256"},{"name":"num","type":"uint256"}],"name":"Buy","outputs":[{"name":"","type":"uint256"}],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":False,"inputs":[{"name":"userAddress","type":"address"},{"name":"role","type":"uint256"}],"name":"addRole","outputs":[],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":False,"inputs":[{"name":"orderNo","type":"uint256"},{"name":"num","type":"uint256"},{"name":"foodId","type":"uint256"},{"name":"price","type":"uint256"}],"name":"createOrder","outputs":[{"name":"","type":"uint256"}],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":True,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":False,"inputs":[{"name":"userAddress","type":"address"},{"name":"company","type":"string"},{"name":"location","type":"string"},{"name":"tel","type":"string"},{"name":"incharge","type":"string"},{"name":"mainBusiness","type":"string"},{"name":"businessType","type":"uint256"}],"name":"createMember","outputs":[],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":True,"inputs":[{"name":"id","type":"uint256"}],"name":"getTransport","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"uint256"},{"name":"","type":"address"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":True,"inputs":[],"name":"getFoodNum","outputs":[{"name":"","type":"uint256"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":True,"inputs":[{"name":"orderNo","type":"uint256"}],"name":"getOrder","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"address"},{"name":"","type":"uint256"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":False,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":False,"stateMutability":"nonpayable","type":"function"},{"constant":True,"inputs":[{"name":"id","type":"uint256"}],"name":"getBuy","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"address"}],"payable":False,"stateMutability":"view","type":"function"},{"constant":True,"inputs":[],"name":"getid","outputs":[{"name":"","type":"uint256[]"}],"payable":False,"stateMutability":"view","type":"function"},{"inputs":[],"payable":False,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":False,"inputs":[{"indexed":True,"name":"previousOwner","type":"address"},{"indexed":True,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}]
redis_service = redis.StrictRedis(host="127.0.0.1", port=6379, db=0)
